package com.atguigu.dwm.common.scheduler;


import com.atguigu.dwm.lineage.service.LineageInfoService;
import com.atguigu.dwm.model.service.DmTableSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Slf4j
public class CommonScheduler {


    @Autowired
    DmTableSyncService dmTableSyncService;

    // 凌晨3点半执行一次 每日
    @Scheduled(cron = "0 30 3 * * *")
    public  void test001(){
        System.out.println("  定时任务 秒级= " +new Date());

    }

 //    @Scheduled(cron = "0 * * * * *")
    public  void  execSyncDataInfo() throws Exception {
        log.info("定时任务 execSyncDataInfo  开始执行 = " +new Date());
        dmTableSyncService.syncDataInfoForScheduler();
        log.info("定时任务 execSyncDataInfo   执行结束 = " +new Date());
    }


    @Autowired
    LineageInfoService lineageInfoService;

    @Scheduled(cron = "0 0 3 * * *")
    public  void  execExtractLineageInfo() throws Exception {
        log.info("定时任务 execSyncDataInfo  开始执行 = " +new Date());
        lineageInfoService.extractLineageInfo();
        log.info("定时任务 execSyncDataInfo   执行结束 = " +new Date());
    }
}
